<?php

namespace Drupal\shusy_errand\Entity;

use Drupal\shusy_errand\ViewsController\Traits\ShusyErrandStatusTrait;
use Entity;

class ShusyErrand extends Entity {

  public $id;

  public $vid;

  public $uid;

  public $op_uid;

  public $created;

  public $changed;

  public $is_new_revision;

  public $errand_id = 0;

  public $is_admin = 0;

  public $team;

  public $city_id;

  public $city;

  public $name;

  public $phone;

  public $status = 0;

  use ShusyErrandStatusTrait;

  function __construct($values = []) {
    $this->is_new_revision = TRUE;
    parent::__construct($values, 'shusy_errand');
  }

  public function save() {
    $this->changed = REQUEST_TIME;
    if (empty($this->created)) {
      $this->created = REQUEST_TIME;
    }

    $this->op_uid = $GLOBALS['user']->uid;

    return parent::save();
  }

}
